//TFX Hosted API: for use by widget iframes and stuff.
(function($) { 
	$.pm.bind('tfxHostedResponse', function(data) {
		alert("got some dataz: " + data);
	}, 'http://www.christianforums.com');
	
	/*
	 * Use like:
	 * $.postMessage({
	 * 		widget: 'reports',
	 * 		message: 'doPost',
	 * 		data: {}
	 * });
	 */
	$.postMessage = function(options, callback) {
		if (!callback) {
			callback = function() {};
		}
		
		$.pm({
			target: window.parent,
			type : 'tfxHostedRequest',
			data : {
				widget: options.widget,
				message: options.message,
				data: options.data
			},
			error : function(e) { alert('hostedRequest error: ' + e.message); },
			success: function(response) {
				callback(response);
			}
		});
	}
})(jQuery);